import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProductQuery, ProductListVO, ServiceAgentForm, ServiceAgentVo, SaveServiceAgentForm } from './types';
import { LocationQueryValue } from 'vue-router';

/**
 * 查询业务类型
 * @param query
 */
export const selBusType = () => {
  return request({
    url: '/payment/proInfo/selBusType',
    method: 'get',
  });
};

/**
 * 查询产品列表
 * @param query
 */
export const productList = (query: ProductQuery): AxiosPromise<ProductListVO[]> => {
  return request({
    url: '/payment/merchantProduct/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询服务商
 */
export const selAgentService = (merchantId:LocationQueryValue | LocationQueryValue[]): AxiosPromise<ServiceAgentVo[]> => {
  return request({
    url: '/payment/proInfo/selAgentService',
    method: 'get',
    params:{
      merchantId
    }
  });
};

/**
 * 添加服务商
 */
export const merchantProductSyd = (data: ServiceAgentForm) => {
  return request({
    url: '/payment/merchantProductSyd',
    method: 'post',
    params: data
  });
};

/**
 *  保存设置
 */
export const merchantProduct = (data: SaveServiceAgentForm) => {
  return request({
    url: '/payment/merchantProduct',
    method: 'post',
    data
  });
};


export default {
  selBusType,
  productList,
  selAgentService,
  merchantProductSyd,
  merchantProduct,

};
